<{include file="Public/top.html" }>
</head>
<body>
<div id="warpper">
    <div class="content">
        <div class="location">转盘抽奖</div>
        <{include file="./nav.html" }>

        <div class="filedSet" style="padding-bottom: 0;">
            <div class="search">
                <form action="" id="searchForm" method="get" class="ui-form reportForm">
                    <input name="m" type="hidden" value="<{$module}>">
                    <input name="c" type="hidden" value="<{$controller}>">
                    <input name="a" type="hidden" value="<{$action}>">

                    <input name="p" id="page" type="hidden" value="<{$page|default:1}>">
                    <input name="limit" id="limit" type="hidden" value="<{$limit|default:10}>">

                    <div class="ui-form-item inline-block">
                        <label class="ui-label">开始时间</label>
                        <input  id="startDate2" name="beginDate" class="date ui-select" type="text" value="<{$beginDate}>" required readonly/>
                    </div>
                    <div class="ui-form-item inline-block">
                        <label class="ui-label">结束时间</label>
                        <input  id="endDate2" name="endDate" class="date ui-select" type="text" value="<{$endDate}>" required readonly/>
                    </div>

                    <div class="ui-form-item inline-block">
                        <label class="ui-label">活动名</label>
                        <select name="active"  class="ui-select" >
                            <option value="">全部</option>
                            <{html_options options=$activeKv selected=$active}>
                        </select>
                    </div>
                    <div class="ui-form-item inline-block">
                        <label class="ui-label">转盘名</label>
                        <select name="turn"  class="ui-select" >
                            <option value="">全部</option>
                            <{html_options options=$turnKv selected=$turn }>
                        </select>
                    </div>
                    <div class="ui-form-item inline-block">
                        <label class="ui-label">获取条件</label>
                        <select name="gotWay"  class="ui-select" >
                            <option value="">全部</option>
                            <{html_options options=$gotWayKv selected=$gotWay }>
                        </select>
                    </div>


                    <div class="ui-form-item inline-block">
                        <button type="submit" class="ui-button" onclick="LayerShow();">搜索</button>
                    </div>

                </form>
            </div>
        </div>


        <!--表格内容-->
        <div class="mainGrid">
            <table class="ui-table ui-body">
                <thead>
                <tr>
                    <th class="pct10">编号</th>
                    <th class="pct15">设置时间</th>
                    <th class="pct20">关联名称</th>
                    <th class="pct20">活动名</th>
                    <th class="pct20">转盘名</th>
                    <th class="pct20">开始时间<br />结束时间</th>

                    <th class="pct10">条件</th>
                    <th class="pct10">剩余领取次数<br />已被领取次数</th>
                    <th class="pct20 last-col">操作</th>
                </tr>
                </thead>
                <tbody>
                <{if $data}>
                    <{foreach from=$data item=item}>
                    <tr>
                        <td><{$item.id}> <a href="javascript:void(0)" onclick="copyUrl(<{$item.id}>)">复制</a></td>
                        <td><{$item.addTime|date_format:'%Y-%m-%d <br/> %H:%M:%S'}></td>
                        <td><{$item.title}></td>
                        <td title="<{$activeKv[$item.active]}>"><{$activeKv[$item.active]}></td>
                        <td><{$turnKv[$item.turn]}></td>
                        <td><{$item.applyStartTime}><br />
                            <{$item.applyEndTime}>
                        </td>
                        <td><{$item.gotWay}></td>
                        <td>
                            <{$item.limit}>

                        </td>

                        <td>
                            <a onclick='connect("<{u('connect?mid='|cat:$item['id'])}>")'  href="javascript:void(0)" >修改</a><span class="sep">|</span>
                            <a onclick='deleteMapping("<{u('deleteMapping?mid='|cat:$item['id'])}>",this)'  href="javascript:void(0)" >删除</a><span class="sep">|</span>
                            <a href="<{u('prizeLog?mapping='|cat:$item['id'])}>" > 抽奖记录</a><span class="sep">|</span>
                            <a onclick='connect("<{u('chance?mid='|cat:$item['id'])}>")'  href="javascript:void(0)"  title="添加可参与名单">添加可参与名单</a>
                        </td>
                    </tr>
                    <{/foreach}>
                <{else}>
                    <tr><td colspan="7">无中奖记录</td></tr>
                <{/if}>
                </tbody>
            </table>
        </div>
        <div class="pagination">
            <!--描述：分页-->
            <{include file="Public/page.html" }>
        </div>
    </div>
</div>
<{include file="Public/foot.html" }>
</body>
</html>
<script>
    datePickter('startDate2','endDate2',true);

    function connect(url){
        layer.open({
            type: 2,
            title: false,
            closeBtn:1, //不显示关闭按钮
            shade: [0],
            area: ['600px', '700px'],
            content: [url, 'no'], //iframe的url，no代表不显示滚动条
        });
    }
    function deleteMapping(url,obj){
        if(!window.confirm("确定删除吗？删除后不可恢复")){
            return false;
        }
        layer.load();
        $.get(url,function(res){
            layer.closeAll();
            layer.msg(res.msg);
            if(res.status==0){
                $(obj).parents("tr").empty();
            }
        },'json');
    }

   function copyUrl(id){
            var textArea = document.createElement("textarea");
            textArea.style.position = 'fixed';
            textArea.style.top = '0';
            textArea.style.left = '0';
            textArea.style.width = '2em';
            textArea.style.height = '2em';
            textArea.style.padding = '0';
            textArea.style.border = 'none';
            textArea.style.outline = 'none';
            textArea.style.boxShadow = 'none';
            textArea.style.background = 'transparent';
            textArea.value = "<{$domain}>/wap.php?m=Wap&c=Turn&a=index&mid="+id;
            document.body.appendChild(textArea);
            textArea.select();

            try {
                var successful = document.execCommand('copy');
                var msg = successful ? '成功复制到剪贴板' : '该浏览器不支持点击复制到剪贴板';
                alert(msg);
            } catch (err) {
                alert('该浏览器不支持点击复制到剪贴板');
            }

            document.body.removeChild(textArea);
   }


</script>
